//
//  ProfileCellView.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2020/2/28.
//  Copyright © 2020 tao Tao. All rights reserved.
//

import UIKit

protocol ProfileCellViewDelegate: NSObjectProtocol {
    func cellView(didTapped view: ProfileCellView)
}

class ProfileCellView: UIView {
    
    weak var delegate: ProfileCellViewDelegate?

    override func awakeFromNib() {
        super.awakeFromNib()
        
        layer.cornerRadius = 8
        layer.masksToBounds = true
        
        let tap = UITapGestureRecognizer(target: self, action: #selector(didTapped(_:)))
        addGestureRecognizer(tap)
    }
    
    @objc private func didTapped(_ tap: UITapGestureRecognizer) {
        switch tap.state {
        case .began:
            backgroundColor = .mainLight
        case .ended:
            backgroundColor = .white
        default: break
        }
        
        delegate?.cellView(didTapped: self)
    }
}
